package object;



class Node{
    public String value;
    //每个元素
    public Node next;
    //每个节点

    public Node(String value) {
        this.value = value;
        this.next = null;
    }
}

public class MyLinkedList {
    private Node head = null;

    public void addFirst(String value){
        Node newNode = new Node(value);
        newNode.next = head;
        head = newNode;
    }

    public void add(int index,String value){

    }

    public void addLast(String value){
        if(head == null){
            Node newNode = new Node(value);
            head = newNode;
            return;
        }

        Node tail = head;
        for(;tail != null;tail = tail.next){
            if(tail.next == null){
                break;
            }
        }
        Node newNode = new Node(value);
        tail.next = newNode;
        newNode.next = null;
    }

    public String toString(){
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("[");
        for(Node cur = head;cur != null;cur = cur.next){
            stringBuilder.append(cur.next);
            if(cur.next != null){
                stringBuilder.append(",");
            }
        }
        stringBuilder.append("]");
        return stringBuilder.toString();
    }






    public static void main(String[] args) {


    }

}
